package ie.deloitte.cvapp.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;


@Entity
@Table(name = "employee_has_skill", catalog = "javabootcamp", schema = "")
/*@NamedQueries({
	@NamedQuery(name = "Skills.findAll", query = "SELECT sk FROM Skills sk"),
	@NamedQuery(name = "Skills.findByIdSkills", query = "SELECT sk FROM Skills sk WHERE sk.idSkill = :idSkill")})
*/
public class EmployeeHasSkill implements Serializable{
	private static final long serialVersionUID = 1L;
	
	
	@Size(max = 120)
    @Column(name = "level", length = 120 )
    private String level;

    @Id
    @ManyToOne
    private Employee employee;

    @Id
    @ManyToOne
    private Skills skill;
    
	public EmployeeHasSkill() {		
	}
	
	public EmployeeHasSkill(String level){
		this.setLevel(level);
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public Skills getSkill() {
		return skill;
	}

	public void setSkill(Skills skill) {
		this.skill = skill;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((employee == null) ? 0 : employee.hashCode());
		result = prime * result + ((skill == null) ? 0 : skill.hashCode());
		result = prime * result
				+ ((level == null) ? 0 : level.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EmployeeHasSkill other = (EmployeeHasSkill) obj;
		if (employee == null) {
			if (other.employee != null)
				return false;
		} else if (!employee.equals(other.employee))
			return false;
		if (skill == null) {
			if (other.skill != null)
				return false;
		} else if (!skill.equals(other.skill))
			return false;
		if (level == null) {
			if (other.level != null)
				return false;
		} else if (!level.equals(other.level))
			return false;
		return true;
	}
	
	
}
